package com.module.shici.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.fenghuajueli.libbasecoreui.baseswitch.PublicFunction;
import com.fenghuajueli.libbasecoreui.utils.MyStatusBarUtils;
import com.module.shici.R;
import com.module.shici.adapter.StoryRvAdapter;
import com.module.shici.room.Music;

import java.util.List;

public class YinPinListActivity extends AppCompatActivity {

    private RecyclerView yinpin_list_rv;
    private TextView tvTitle;
    private String title;
    private int imgType;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.module_shici_activity_yin_pin_list);
        MyStatusBarUtils.setStatusBar(this,"#00000000");
        yinpin_list_rv = findViewById(R.id.yinpin_list_rv);
        tvTitle = findViewById(R.id.yinpin_list_title);
        //返回
        findViewById(R.id.yinpin_list_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        title = getIntent().getStringExtra("title");
        //获取标题
        tvTitle.setText(title);
        imgType = getIntent().getIntExtra("imgType", 1);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
        yinpin_list_rv.setLayoutManager(gridLayoutManager);
        StoryRvAdapter storyRvAdapter = new StoryRvAdapter((List<Music>) getIntent().getSerializableExtra("musicList"), imgType);
        yinpin_list_rv.setAdapter(storyRvAdapter);
        storyRvAdapter.getStoryUrl(new StoryRvAdapter.StoryListener() {
            @Override
            public void setStoryUrl(@Nullable String url, @Nullable int position) {
                if (!PublicFunction.checkCanUsedByPosition(3, true)) {
                    return;
                }
                Intent intent = new Intent(YinPinListActivity.this, VoiceActivity.class);
                intent.putExtra("ID", position);
                intent.putExtra("imgType", imgType);
                startActivity(intent);
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
}